import request from '@/utils/request'
import axMock from '@/utils/mock'
export  interface cartModel {
    id: number
    userId: string
    skuId: number
    cartPrice: number
    skuNum: number
    imgUrl: string
    skuName: string
    isChecked: number
    createTime: string
    operateTime: string
    isOrdered: number
    orderTime: null
    sourceType: string
    sourceId: number
    skuPrice: number
    couponInfoList: null
}
export type cartListData = cartModel[]
export interface carts {
    cartInfoList:cartListData,
    activityRuleList:null,
    createTime:string
}
export interface cartList{
    data:carts[]
}

export default {
      // 获取购物车列表数据
      reqCartList(){
        return request.get<any,any>(`/app-dev/api/cart/cartList`)
    },
    //模拟购物车数据
    getCartList(){
        return axMock.get<any,any>('/cartList')
    },
    //修改商品选中状态
    reqCheckCart(skuId:number,isChecked:number){
        return request.get<any,any>(`/app-dev/api/cart/checkCart/${skuId}/${isChecked}`)
    },
    //批量选中购物车
    reqBatchCheckCart(isChecked:number,skuIdList:any){
        return request.post(`/app-dev/api/cart//batchCheckCart/${isChecked}`,skuIdList)
    },
    //添加购物车接口,,用这个接口主要是为了 - + 修改商品数量
    reqAddCart(skuId:number,skuNum:number){
        return request.post(`/app-dev/api/cart/addToCart/${ skuId }/${ skuNum }`)
    },
    //删除购物车商品
    reqDeleteCart(skuId:number){
        return request.delete(`/app-dev/api/cart/deleteCart/${ skuId }`)
    }
}